<%@ page contentType="text/html; charset=UTF-8" import="java.util.*,java.sql.*" %>
<%
    String sort=request.getParameter("sort");
    String driver = "oracle.jdbc.driver.OracleDriver";
    String connectionURL = "jdbc:oracle:thin:@oracle.students.itee.uq.edu.au:1521:iteeo"; 
    Connection conn = null;
    Statement st = null;
    ResultSet rs = null;
    List questionid = new ArrayList();

    try{
        Class.forName(driver); 
    } catch(java.lang.ClassNotFoundException e) {
        e.printStackTrace();
    }

    try {
        conn = DriverManager.getConnection(connectionURL,"CSSE3004GE","967431"); 
        st=conn.createStatement();
        rs=st.executeQuery("SELECT Poll_Question.QuestionID FROM Poll_Question where Poll_Question.PollID='"+sort+"'");
        while (rs.next())
        {
            questionid.add(rs.getString(1));
        }
        rs.close();
        st.close();
        conn.close();
    }  catch (Exception e)  {   
        e.printStackTrace();
    }
    response.setContentType("text/xml; charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    out.println("<response>");
    for(int i=0;i<questionid.size();i++)
    {
        out.println("<res>" + questionid.get(i).toString() + "</res>");
    }
    out.println("</response>");
    out.close();
%>